// const WXAPI = require("../../wxapi/main");
// const CONFIG = require("../../config.js");

// var t = require("../../nitro.js"),
//   e = (require("../../configs.js"), getApp());


  const WXAPI = require("apifm-wxapi");
const TOOLS = require("../../utils/tools.js");
const AUTH = require("../../utils/auth");
const e = require("../../config.js");
const APP = getApp();


Page({
  data: {
    stores: [],
    xitems: [],
  },
  onLoad: function (t) {
  
  },
  onReady: function () {},

  // 分享
  onShareAppMessage: function () {
    return {
      title: "简.空间摄影",
    };
  },
  //用户点击右上角分享朋友圈
  onShareTimeline: function () {
    return {
      title: "简.空间摄影",
    };
  },

  onShow: function () {
    let that = this;
    console.log(11111);
    // var a = this, o = t.getStore();

    // wx.setNavigationBarTitle({
    //     title: "" + o.name
    // }),

    // delete e.globalData.categories, delete e.globalData.items, delete e.globalData.themeGroups;


    // const res = await WXAPI.fetchShops(p)
    // if (res.code == 0) {
    //   res.data.forEach(ele => {
    //     if (ele.distance) {
    //       ele.distance = ele.distance.toFixed(3) // 距离保留3位小数
    //     }
    //   })
    //   this.setData({
    //     shops: res.data
    //   })
    // }


    WXAPI.fetchShops().then(function (res) {
      console.log(res);
      if (res.code == 0) {
        console.log(res);

        that.setData({
          xitems: res.data,
        });
      }
      console.log(that.data.xitems);
    });

    // WXAPI.goodsCategory().then(function(res) {
    //     let categories = [];
    //     if (res.code == 0) {
    //       categories = categories.concat(res.data);
    //       console.log(categories);

    //       that.setData({
    //         loaded: !0,
    //         items: categories,
    //       });

    //     }

    //   })
  },
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  initStores: function () {},
  // 点击跳转
  itemTapHandler: function (a) {
    wx.setStorageSync("jxzmd", a.currentTarget.dataset.id);

    var r = "/pages/artworks/artworks?dianpu=" + a.currentTarget.dataset.id;
    wx.navigateTo({
      url: r,
      success: function (t) {},
      fail: function (t) {},
      complete: function (t) {},
    });

    // var o = a.currentTarget.dataset.storeid,
    //     i = a.currentTarget.dataset.type,
    //     n = this.data.stores.find(function(t) {
    //     return t.id === o;
    // });

    // t.setStore(o), e.globalData.cart.store = n, e.globalData.cart.storeId = o;

    // // var r = "/pages/artworks/artworks?store_id=" + o + "&type=" + i;

    // var r = "/pages/artworks/artworks?category_id=329418&type=" + i;

    // if("wj" === i){
    //     r = "/pages/product-detail/product-detail?category_id=329417&type=" + i
    // }

    // wx.navigateTo({
    //     url: r,
    //     success: function(t) {},
    //     fail: function(t) {},
    //     complete: function(t) {}
    // });
  },
});
